package com.cecsmsserve.controller;


import com.cecsmsserve.entity.UserActivity;
import com.cecsmsserve.service.IUserActivityService;
import com.cecsmsserve.util.result.CommonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 王郝浠
 * @since 2024-04-22
 */
@CrossOrigin
@RestController
@RequestMapping("/userActivity")
public class UserActivityController {

    @Autowired
    IUserActivityService service;

    @GetMapping("/selectAll")
    public CommonResult selectAll(){
        return service.selectAll();
    }

    @GetMapping("/selectAllByPage/{current}/{size}")
    public CommonResult selectAllByPage(@PathVariable("current") int current,@PathVariable("size")int size){
        return service.selectAllByPage(current,size);
    }

    @GetMapping("/selectAllByuId/{uId}")
    public CommonResult selectAllByuId(@PathVariable int uId){
        return service.selectAllByuId(uId);
    }

    @GetMapping("/selectByUIdBymyState/{uId}/{state}")
    public CommonResult selectByUIdBymyState(@PathVariable int uId,@PathVariable String state){
        return service.selectByUIdBymyState(uId,state);
    }

    @GetMapping("/selectByUIdByState/{uId}/{state}")
    public CommonResult selectByUIdByState(@PathVariable int uId,@PathVariable String state){
        return service.selectByUIdByState(uId,state);
    }

    @GetMapping("/selectByuIdByaId/{uId}/{aId}")
    public CommonResult selectByuIdByaId(@PathVariable int uId,@PathVariable int aId){
        return service.selectByuIdByaId(uId,aId);
    }

    @GetMapping("/selectUserByaId/{aId}")
    public CommonResult selectUserByaId(@PathVariable int aId){
        return service.selectUserByaId(aId);
    }

    @PutMapping("/insert")
    public CommonResult insert(@RequestBody UserActivity userActivity){
        return service.insert(userActivity);
    }

    @PostMapping("/update")
    public CommonResult update(@RequestBody UserActivity userActivity){
        return service.update(userActivity);
    }
}
